package com.ojoin.ojoin.eb_spider.utils;

import java.beans.Introspector;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.ojoin.ojoin.eb_spider.service.impl.SLDataCatchBaseServiceImpl;

public class SpringUtilsSpider {
	
	private static  Logger log = LoggerFactory
			.getLogger(SLDataCatchBaseServiceImpl.class);
	
	private static ApplicationContext ctx = new ClassPathXmlApplicationContext(
			"/spring-config.xml","/spring-config-activeMQ.xml");// 读取bean.xml中的内容
 
	public static void init() {
		log.info("init Spring");
	}

	@SuppressWarnings("unchecked")
	public static <T> T getBeanByClassName(String clazzName) {
		if (StringUtils.isEmpty(clazzName)) {
			return null;
		}

		String beanName = Introspector.decapitalize(clazzName);

		return (T) ctx.getBean(beanName);
	}

}
